package practice;

import java.util.Stack;

public class Day10 {
    public int test1(String s) {
        int left = 0;
        int right = 0;
        int n = s.length();
        int max = 0;
        while(right < n) {
            max = Math.max(max,right - left + 1);
            if(right + 1 < n && s.charAt(right) != s.charAt(right + 1)) {
                left = right + 1;
            }
            right++;
        }
        return max;
    }

    static class Node {
        public int val;
        public Node right;
        public Node left;
        public Node(int val) {
            this.val = val;
        }
    }
    public void test2(Node root) {
        Node cur = root;
        Stack<Node> stack = new Stack<>();
        Node prev = null;
        while(cur != null || !stack.isEmpty()) {
            while(cur != null) {
                stack.push(cur);
                cur = cur.left;
            }
            Node top = stack.peek();
            if(top.right == null || prev != top.right) {
                System.out.print(top.val + " ");
                stack.pop();
                prev = top;
            }else {
                cur = top.right;
            }
        }
    }
}
